<?php

namespace app\service;

use app\exception\CommonException;
use app\model\Order;

class OrderService extends BaseService
{


    protected function setModel(): string
    {
        return Order::class;
    }

    public function set($id,$control)
    {
        $res = $this->get($id, ["status"]);
        if (empty($res)) {
            throw new CommonException("不存在对应的订单");
        }
        if ($res->status != Order::ORDER_STATUS_PENDING ) {
            throw new CommonException("订单已经结算");
        }
        return $this->save(["id" => $id, "control" => $control]);
    }

}